#include <iostream>

using namespace std;

class Singleton{
private:
    Singleton(){}
    ~Singleton(){}
    static Singleton *_ps;

public:
    static Singleton *getInstance(){
        if(_ps==nullptr){
            _ps=new Singleton();
        }
        return _ps;
    }

    void print(){
        cout << "Singlet::print()" << endl;
    }

    static void destroy(){
        if(_ps){
            delete _ps;
            _ps=nullptr;
        }
    }

    Singleton(const Singleton &)=delete;
    Singleton &operator=(const Singleton &)=delete;
};

Singleton *Singleton::_ps=nullptr;

void test(){
    Singleton *ps1=Singleton::getInstance();
    Singleton *ps2=Singleton::getInstance();
    cout << ps1 << endl;
    cout << ps2 << endl;
    Singleton::destroy();
    Singleton::destroy();
}

int main()
{
    test();
    return 0;
}

